/**
 * @author 太阳当空丶赵
 * @date 2022/11/30-22:41
 * @version 1.0.0
 * getDownloadUrl
 */
const axios = require("axios")
const {wx} = require('../config')
// const getToken = require("./getToken")
module.exports = function (cloudPath){
    return new Promise((resolve, reject) => {
        // const token = getToken()
        // const getUrl = `https://api.weixin.qq.com/tcb/batchdownloadfile?access_token=${token}`
        const getUrl = `http://api.weixin.qq.com/tcb/batchdownloadfile` // 云调用
        const data = {
            "env": wx.EnvId,
            "file_list": [
                {
                    "fileid":cloudPath,
                    "max_age":7200
                }
            ]
        }
        axios.post(getUrl,data).then(result => {
            const data = result.data.file_list[0]
            console.info("get download url",data['download_url'])
            resolve(data['download_url'])
        }).catch(err => {
            console.info("download err",err)
            reject(false)
        })

    })
}
